package acwing;

import java.io.*;
import java.util.*;

public class groupBag {
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
    static final int N = 110;
    static int n, m;
    static int[][] w = new int[N][N], v = new int[N][N];
    static int[] f = new int[N], s = new int[N];

    static int cin() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws IOException {
        n = cin(); m = cin();
        for (int i = 1; i <= n; i ++ ) {
            s[i] = cin();
            for (int j = 1; j <= s[i]; j ++ ) {
                v[i][j] = cin();
                w[i][j] = cin();
            }
        }
        for (int i = 1; i <= n; i ++ ) {
            for (int j = m; j >= 0; j -- ) {
                for (int k = 1; k <= s[i]; k ++ ) {
                    if (v[i][k] <= k)
                        f[j] = Math.max(f[j], f[j - v[i][k]] + w[i][k]);
                }
            }
        }
        out.println(f[m]);
        out.close();
    }
}